package com.woniuxy01;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-05-28 15:15
 */
public class MyUitl {

    //玩家出拳：不是1，2，3,直到有效
    public int userShow(){
        Scanner sc = new Scanner(System.in);
        int userShow;
        boolean flag=true;
        do {
            if (flag) {
                System.out.println("玩家出拳,1.剪刀；2.石头3.布");
            } else {
                System.out.println("出拳错误，只能输入1，2，3：1.剪刀；2.石头3.布");
            }
            userShow = sc.nextInt();
            if (!(userShow == 1 || userShow == 2 || userShow == 3)) {
                flag = false;
            }else{
                flag=true;
            }
        } while (!flag);
        return userShow;
    }

    //电脑出拳
    public int computerShow(){
        return (int)(Math.random()*100)%3+1;
    }

    //根据用户的输入显示出拳
    public String showFistName(int show){
        String showName=null;
        switch (show) {
            case 1:
                showName = "剪刀";
                break;
            case 2:
                showName = "石头";
                break;
            case 3:
                showName = "布";
                break;
        }
        return showName;
    }
}
